//
//  ResultViewController.m
//  XDCommonApp
//
//  Created by xindao on 14-6-30.
//  Copyright (c) 2014年 XD-XY. All rights reserved.
//

#import "ResultViewController.h"
#import "QRCodeGenerator.h"
@interface ResultViewController ()

@end

@implementation ResultViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];

    self.titleLabel.text = @"支付完成";

    backScrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, UI_SCREEN_WIDTH, UI_MAINSCREEN_HEIGHT - UI_NAVIGATION_BAR_HEIGHT)];
    backScrollView.delegate = self;
    backScrollView.contentSize = CGSizeMake(UI_SCREEN_WIDTH, 515);
    backScrollView.pagingEnabled = NO;
    [self.contentView addSubview:backScrollView];

    UIImageView * titleIV = [[UIImageView alloc] initWithFrame:CGRectMake(74, 25, 30, 30)];
    titleIV.image = [UIImage imageNamed:@"pay_over"];
    [backScrollView addSubview:titleIV];

    [XDTools addAlabelForAView:backScrollView withText:@"订单支付完成" frame:CGRectMake(112,29,125,27) font:[UIFont systemFontOfSize:20]
                     textColor:RGBA(124, 88, 209, 1)];

    codeIV = [[UIImageView alloc] initWithFrame:CGRectMake(45, 70, 230, 230)];
    codeIV.image = [QRCodeGenerator qrImageForString:_code imageSize:codeIV.bounds.size.width];
    codeIV.layer.borderColor = [UIColor lightGrayColor].CGColor;
    codeIV.layer.borderWidth = 1;
    [backScrollView addSubview:codeIV];

    [XDTools addAlabelForAView:backScrollView withText:@"凭此码领取活动奖品" frame:CGRectMake(85,315,170,20) font:[UIFont systemFontOfSize:17]
                     textColor:RGBA(133, 133, 133, 1)];

    self.shareView = [[XDShareView alloc]initWithFrame:CGRectMake(0, 0, UI_SCREEN_WIDTH, UI_SCREEN_HEIGHT)];
    _shareView.delegate = self;
    [self.view addSubview:_shareView];
    
    [XDTools getAButtonForView:backScrollView frame:CGRectMake(90, 345, 145, 44) nomalTitle:nil hlTitle:nil titleColor:nil bgColor:nil nbgImage:@"share" hbgImage:@"share" action:@selector(shareBtnClick) target:self buttonTpye:UIButtonTypeCustom];
    [XDTools getAButtonForView:backScrollView frame:CGRectMake(15, 420, 290, 99/2.0f) nomalTitle:nil hlTitle:nil titleColor:nil bgColor:nil nbgImage:@"wancheng" hbgImage:@"wancheng" action:@selector(overBtnClick) target:self buttonTpye:UIButtonTypeCustom];


}



- (void)overBtnClick{
    [self.navigationController popToRootViewControllerAnimated:YES];
}


#pragma mark ================分享按钮点击===================
-(void)shareBtnClick
{
    [_shareView setViewShow];
    DDLOG_CURRENT_METHOD;
}

#pragma mark ===============xdshareview delegate==========
-(void)shareViewBtnCLick:(UIButton *)button
{
    if (button.tag == 1001){
        [[UMSocialControllerService defaultControllerService] setShareText:@"我刚刚使用“喵贷”，得到了我朝思暮想的ta！你也一起来试试吧！喵贷，青春专属信贷应用，一次购物分期支付，无需抵押，不用证明，只要拿出诚意、亮出诚信，你和你的梦想只有一个app的距离！点击链接极速下载：" shareImage:[UIImage imageNamed:@"Icon"] socialUIDelegate:self];
        [UMSocialData defaultData].extConfig.title = @"喵贷信用支付";
        [UMSocialSnsPlatformManager getSocialPlatformWithName:UMShareToSina].snsClickHandler(self,[UMSocialControllerService defaultControllerService],YES);
    }else{
        //朋友圈分享
        [[UMSocialControllerService defaultControllerService] setShareText:@"我刚刚使用“喵贷”，得到了我朝思暮想的ta！你也一起来试试吧！喵贷，青春专属信贷应用，一次购物分期支付，无需抵押，不用证明，只要拿出诚意、亮出诚信，你和你的梦想只有一个app的距离！点击链接极速下载：" shareImage:[UIImage imageNamed:@"Icon"] socialUIDelegate:self];
        [UMSocialData defaultData].extConfig.title = @"喵贷信用支付";
        [UMSocialSnsPlatformManager getSocialPlatformWithName:UMShareToWechatTimeline].snsClickHandler(self,[UMSocialControllerService defaultControllerService],YES);
    }
}


- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
